﻿#ifndef LOGINDLG_H
#define LOGINDLG_H

#include <QDialog>
#include <QMessageBox>
#include <QWidgetList>
#include <QListWidgetItem>
#include <QComboBox>
#include <QGroupBox>
#include <QLineEdit>
#include <QCheckBox>
#include <QLabel>
#include <QPushButton>
#include <QSettings>
#include "accountitem.h"
#include "msgbox.h"
#include "../mainwindow.h"
#include"../ufxconfig.h"
#include"../CtpInterface/ctpinterface.h"

class CLoginDlg : public QDialog
{
	Q_OBJECT

public:
	//Ui::LoginDlg ui;
	QGroupBox *loginGroup;
	QLabel *labelServerSel;
	QLabel *labelUser;
	QLabel *labelPassword;
	QLineEdit *editPassword;
	QCheckBox *checkSaveFlag;
	QPushButton *btnLogin;
	QPushButton *btnCancel;
	QComboBox *cmbServerList;
	QLineEdit *editBrokerId;
	QLabel *labelBrokerId;
	QComboBox *cmbUsername;
	QListWidget *listWidget;
	QLabel *labelStatus;

	MsgBox *msgBox; //删除用户提示界面


signals:
	void SigShowStatusText(QString msg);

public slots:
    void showAccount(QString sText);
    void removeAccount(QString sText);
	//CTP服务器反馈
    void OnRspUserLoginTrade(CThostFtdcRspInfoField *pRspInfo);
    ///登录请求响应
    void OnRspUserLoginMarket(CThostFtdcRspInfoField *pRspInfo);

	void ShowStatusText(QString text);

public:
	CLoginDlg(QWidget *parent = 0);
	~CLoginDlg();
	void userLogin(void);
	void cancelLogin();
	void displayUser(QString account);
    void removeUser(QString account);
    //查询合约信息完毕后调用函数
    void OnRspQryInstrument();

    void ReadIniFile();

private:
    //CTP服务器反馈信息
    bool m_bCTPTraderResponsed;
    bool m_bCTPMarketResponsed;

	bool m_iErrorID;
    QString m_strCTPErrorMsg;

	bool			m_dbOk;
    //用户名和密码
    QString			m_szUsername;
    QString			m_szPassword;
    QString			m_szBrokerId;

    QSettings*		m_AccountSettings;
    QSettings*		m_ServerSettings;
};

#endif //LOGINDLG_H
